package com.qymerge.manage.base.service.impl;

import com.qymerge.manage.base.dao.IMetaAccountViewDao;
import com.qymerge.manage.base.ro.MetaAccountViewRO;
import com.qymerge.manage.base.service.IMetaAccountViewService;
import com.qymerge.manage.base.service.IMetaCompanyService;
import com.qymerge.manage.core.bean.DataTableRO;
import com.qymerge.manage.core.bean.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>Title: MetaAccountViewServiceImpl</p>
 * <p>Description: 科目</p>
 *
 * @author Xiao
 * @date 2025/4/29 18:43
 * @version 1.0.0
 */
@Service
public class MetaAccountViewServiceImpl implements IMetaAccountViewService {

    @Autowired
    private IMetaAccountViewDao metaAccountViewDao;

    /**
     * 用户管理-查询
     *
     * @param ro
     * @param pageRequest
     * @return
     */
    @Override
    public DataTableRO list(MetaAccountViewRO ro, PageRequest pageRequest) {
        List list = metaAccountViewDao.list(ro, pageRequest);
        DataTableRO dataTableRO = new DataTableRO();
        int allCount = metaAccountViewDao.total(ro);
        int pageSize = pageRequest.getSize();
        dataTableRO.setAll_count(allCount);
        dataTableRO.setList(list);
        dataTableRO.setCurrent_page(pageRequest.getPage());
        dataTableRO.setPage_size(pageSize);
        int allPage = (allCount % pageSize == 0 ? allCount / pageSize : allCount / pageSize + 1);
        dataTableRO.setAll_page(allPage);
        return dataTableRO;
    }

    /**
     * 详情
     *
     * @param code
     * @return
     */
    @Override
    public MetaAccountViewRO detail(String code) {
        return metaAccountViewDao.findOne(code);
    }


}
